Skip to content
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

Explicitly disallow importing an identifier whose type needs to be inferred #5

Open
smarter opened this issue Dec 22, 2016 · 4 comments

Comments

@smarter
Copy link
Contributor

smarter commented Dec 22, 2016

The following code:

class Hi {
  class A
}

class Foo {
  val x = new Hi
  import x._
  def bar: A = new A
}

fails with:

java.lang.RuntimeException: Can't resolve selector Ident(A)

It seems that either importing from something with type InferredTypeMarker should be disallowed or that everything in scope after such an import should get type InferredTypeMarker.

@gkossakowski
Copy link
Owner

Good catch. Importing from terms with inferred types should be disallowed.
Terms with inferred types are already ruled out from appearing in paths (e.g. x.type is not allowed).

@smarter
Copy link
Contributor Author

smarter commented Dec 24, 2016

Terms with inferred types are already ruled out from appearing in paths (e.g. x.type is not allowed).

In your blog post you mentioned that no Scala language feature prevents the use of outline types, but isn't that contradicted by the fact that you have to introduce restrictions like this? How would you deal with this in a real compiler?

@gkossakowski
Copy link
Owner

gkossakowski commented Dec 26, 2016

In the blog post introducing outline types I discussed the difficulty of vals mentioned in paths:

The solution I see is to outlaw such Scala programs: if you have a val that you want to use in path-depent types, it can’t have an inferred type — its type has to be provided explicitly.

At the time, I thought that vals with inferred types has to be only disallowed from appearing in paths. I missed import nodes.

Kentucky Mule is about exploiting a clear boundary between declaration typechecking and expression typechecking for improving the overall speed of typechecking. This boundary almost already exists in Scala except a few cases we're now identifying.

I'm pretty sure Scala users would be willing to give up on inferred types connivence in some cases (in paths and in imports) if they were promised 10x compiler speed upgrade in return.

@smarter
Copy link
Contributor Author

smarter commented Dec 26, 2016

I'm pretty sure Scala users would be willing to give up on inferred types connivence in some cases (in paths and in imports) if they were promised 10x compiler speed upgrade in return.

I agree, just thought that this needed to be clarified :)

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

No branches or pull requests

2 participants