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

Import-renamed method can't be used as partially applied function #7233

Closed
scabug opened this issue Mar 8, 2013 · 6 comments
Closed

Import-renamed method can't be used as partially applied function #7233

scabug opened this issue Mar 8, 2013 · 6 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Mar 8, 2013

The following code doesn't compile:

object Foo { def bar(i: Int) = i }
import Foo.{ bar => quux }
quux _
Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_10).
Type in expressions to have them evaluated.
Type :help for more information.

scala> object Foo { def bar(i: Int) = i }
defined module Foo

scala> import Foo.{ bar => quux }
import Foo.{bar=>quux}

scala> quux _
<console>:10: error: value quux is not a member of object Foo
              quux _
              ^

scala> 

Seems like it should?

@scabug
Copy link
Author

scabug commented Mar 8, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7233?orig=1
Reporter: Max Afonov (maxaf)
Affected Versions: 2.9.2, 2.10.0

@scabug
Copy link
Author

scabug commented Mar 10, 2013

@retronym said:
https://github.com/retronym/scala/compare/ticket/7233

Looks like an endemic problem:

scala> def foo(a: Any) = { import a.{toString => toS}; toS }
unhandled exception while transforming <console>
error: uncaught exception during compilation: scala.reflect.internal.FatalError
scala.reflect.internal.FatalError: class Object does not have a member toS
	at scala.reflect.internal.Definitions$DefinitionsClass.scala$reflect$internal$Definitions$DefinitionsClass$$fatalMissingSymbol(Definitions.scala:1028)

@scabug
Copy link
Author

scabug commented Mar 10, 2013

@retronym said:
scala/scala#2230

@scabug scabug closed this as completed Mar 13, 2013
@scabug
Copy link
Author

scabug commented Mar 26, 2013

@adriaanm said:
Note that the part of the test that imports from Any no longer makes sense on master since Any's members became "unimportable".

@scabug
Copy link
Author

scabug commented Mar 26, 2013

@adriaanm said:
The relevant change was a "minor tweak". Are we sure it's minor, paulp?

commit 632daed4ed
Author: Paul Phillips <paulp@improving.org>
Date:   5 months ago

    Minor tweaks in Types/Scopes.
    
    All methods to do with handling imports more uniformly and early
    filtering of symbols which cannot be imported. Also make TypeBounds
    treat a Wildcard in lower or upper bounds as an empty bound, so we
    don't see all these method signatures like
    
      def f[T >: ? <: ?]
    
    because that's not helpful.

diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index dfc621d60e..78380ad054 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -1006,7 +1006,7 @@ trait Contexts { self: Analyzer =>
     }
 
     def allImportedSymbols: Iterable[Symbol] =
-      qual.tpe.members flatMap (transformImport(tree.selectors, _))
+      importableMembers(qual.tpe) flatMap (transformImport(tree.selectors, _))
 

@scabug
Copy link
Author

scabug commented Mar 26, 2013

@adriaanm said:
opened #7302 to track this

@scabug scabug added the has PR label Apr 7, 2017
@scabug scabug added this to the 2.10.2-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants