Scala Programming Language
  1. Scala Programming Language
  2. SI-7233

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.2, Scala 2.10.0
    • Fix Version/s: Scala 2.10.2-RC1
    • Component/s: Misc Compiler
    • Environment:

      Linux 2.6.x, Mac OS X 10.8.2

      Description

      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?

        Activity

        Hide
        Jason Zaugg added a comment -

        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)
        
        Show
        Jason Zaugg added a comment - 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)
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/2230
        Hide
        Adriaan Moors added a comment -

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

        Show
        Adriaan Moors added a comment - Note that the part of the test that imports from Any no longer makes sense on master since Any's members became "unimportable".
        Hide
        Adriaan Moors added a comment -

        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, _))
         
        
        
        Show
        Adriaan Moors added a comment - 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, _))
        Hide
        Adriaan Moors added a comment -

        opened SI-7302 to track this

        Show
        Adriaan Moors added a comment - opened SI-7302 to track this

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Max Afonov
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development