Skip to content

Test stdlib-bootstrpped ScalaNumericConversions.underlying #18086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion project/TastyMiMaFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ object TastyMiMaFilters {
// Problem? Very complicated signature
ProblemMatcher.make(ProblemKind.IncompatibleTypeChange, "scala.collection.generic.IsMap.mapOpsIsMap"),

// Problem: Overriding java method (`public abstract Object underlying();` with `def underlying: Object`)
// Probably OK: Overriding java method (`public abstract Object underlying();` with `def underlying: Object`)
// Calls to the underlying seem to link correctly.
// Tested in stdlib-bootstrapped/test/Main.scala
ProblemMatcher.make(ProblemKind.MissingTermMember, "scala.math.Big*.underlying"),
ProblemMatcher.make(ProblemKind.NewAbstractMember, "scala.math.ScalaNumericConversions.underlying"),

Expand Down
30 changes: 30 additions & 0 deletions stdlib-bootstrapped-tasty-tests/src/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ object HelloWorld:
testScala2UnapplySignatures()
testScala2ObjectParents()
testScala2CaseClassUnderscoreMembers()
testScalaNumberUnderlying()
}

def testScala2UnapplySignatures() = {
Expand All @@ -37,3 +38,32 @@ object HelloWorld:
val some: Some[Int] = Some(1)
// FIXME: assert(!typeChecks("some._1"))
}

def testScalaNumberUnderlying() = {
import scala.math.{ScalaNumericConversions, ScalaNumber}

val _: java.math.BigInteger = BigInt(1).underlying
val _: Object = (BigInt(1): ScalaNumericConversions).underlying
val _: Object = (BigInt(1): ScalaNumber).underlying

// val _: java.math.BigDecimal = BigDecimal(1).underlying // FIXME: inferred result type of non-private method
val _: Object = (BigDecimal(1): ScalaNumericConversions).underlying
val _: Object = (BigDecimal(1): ScalaNumber).underlying

class MyNumber1(override val underlying: BigInt) extends ScalaNumericConversions {
def doubleValue: Double = ???; def floatValue: Float = ???;
def intValue: Int = ???; def longValue: Long = ???
def isWhole: Boolean = ???
}
val _: BigInt = MyNumber1(1).underlying
val _: Object = (MyNumber1(1): ScalaNumericConversions).underlying
val _: Object = (MyNumber1(1): ScalaNumber).underlying

class MyNumber2(override val underlying: Object) extends ScalaNumber {
def doubleValue: Double = ???; def floatValue: Float = ???;
def intValue: Int = ???; def longValue: Long = ???
def isWhole: Boolean = ???
}
val _: Object = MyNumber2(BigInt(1)).underlying
val _: Object = (MyNumber2(BigInt(1)): ScalaNumber).underlying
}