Skip to content

Nothing inferred in polymorphic, inlined method #7798

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

Closed
biboudis opened this issue Dec 18, 2019 · 2 comments · Fixed by #7804
Closed

Nothing inferred in polymorphic, inlined method #7798

biboudis opened this issue Dec 18, 2019 · 2 comments · Fixed by #7804

Comments

@biboudis
Copy link
Contributor

minimized code

object Test {
  inline def meth[R <: Int]: R = 3.asInstanceOf[R] // inferred type is Nothing
  def main(args: Array[String]): Unit = {
    val t: Int = meth
  }
}

expectation

It should work as in the normal case.

@biboudis
Copy link
Contributor Author

There is something weird in inferencing when instantiation is occurring (in Inferencing.scala when Inferencing.isFullyDefined is called from inliner 🤷‍♂) :

committing TS[8, 1, 0] to TS[1, 0], fromConstr = Constraint(
 uninstVars = ;
 constrained types = [R <: Int] => R
 bounds = 
     R := Nothing
 ordering = 
), toConstr = Constraint(
 uninstVars = R;
 constrained types = [R <: Int] => R
 bounds = 
     R <: Int
 ordering = 
)

@odersky
Copy link
Contributor

odersky commented Dec 19, 2019

Inlining instantiates type arguments to the call. You can try to leave out the isFullyDefined call in the Inliner, but I guess bad things would happen. It seems like a scary feature interaction to inline code that references type variables that are not yet instantiated.

biboudis added a commit to dotty-staging/dotty that referenced this issue Dec 19, 2019
biboudis added a commit to dotty-staging/dotty that referenced this issue Dec 19, 2019
biboudis added a commit that referenced this issue Dec 20, 2019
Fix #7798: Change ForceDegree to noBottom in inline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants