Skip to content

Conversation

@hamzaremmal
Copy link
Member

@hamzaremmal hamzaremmal commented Dec 4, 2025

  • TODO: Write the specification while we are on it.

Closes #21304

tp.isRef(defn.NothingClass) || tp.isRef(defn.NullClass) || (tp eq NoPrefix)

private def isUnderspecified(tp: Type): Boolean = tp.stripTypeVar match
private def isUnderspecified(tp: Type): Boolean = tp.simplified match
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm willing to bet that we also need a dealiasing here.

|| isUnderSpecifiedArgument(tp.argType.widen)
case _ =>
tp.isAny || tp.isAnyRef
case tp => tp.isAny || tp.isAnyRef || tp.isAnyVal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a specification point of view, it would have been nice to check tp.isTopLevel but that means we need to also include scala.Matchable in the list of underspecified types.

Comment on lines +9 to +20
| One of the following imports might fix the problem:
|
| import scala.math.BigDecimal.int2bigDecimal
| import scala.math.BigInt.int2bigInt
| import scala.math.Numeric.IntIsIntegral.mkNumericOps
| import scala.math.Numeric.IntIsIntegral.mkOrderingOps
| import scala.math.Ordering.Int.mkOrderingOps
| import scala.math.Integral.Implicits.infixIntegralOps
| import scala.math.Ordered.orderingToOrdered
| import scala.math.Ordering.Implicits.infixOrderingOps
| import scala.math.Numeric.Implicits.infixNumericOps
| import scala.reflect.Selectable.reflectiveSelectable
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of them will ever help. An improvement would be to get rid of this list when we are underspecified.

implicit def _2: Int = 0

println(implicitly[AnyVal])
println(implicitly[AnyVal]) // error
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was completely bogus before, not only it should have been underspecified but also, if we say AnyVal are not underspecified, it should have been an ambiguous resolution (what actually Scala 2.13.16 says).

Copy link
Member Author

@hamzaremmal hamzaremmal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the changes in the Hylolib suite, my changes somehow triggered the checks for infix in

which is actually a legitimate error. I went ahead and migrate those tests to use infix def since this code base should set an example of coding styles.

@hamzaremmal hamzaremmal self-assigned this Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inconsistent behavior regarding implicit conversion from Int to AnyRef vs Int to AnyRef | Null

1 participant