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

calling extension method with parameter list swallows error message #7907

Open
scabug opened this issue Oct 12, 2013 · 4 comments
Open

calling extension method with parameter list swallows error message #7907

scabug opened this issue Oct 12, 2013 · 4 comments

Comments

@scabug
Copy link

scabug commented Oct 12, 2013

Expected result:
"test".bar and "test".copy() leads to (almost) identical error messages
Actual Result:
"test".bar leads to two error messages and "test".copy() only to one, which can be very surprising.
Reproduce code:

object Foo{
  trait TypedType[T]
  implicit def intColumnType: TypedType[Int] = null
  case class ConstColumn[T](v: T){
    def bar = 5
  }
  implicit def valueToConstColumn[T : TypedType](v: T) = ConstColumn(v)
  5.copy()
  5.bar

  "test".bar // could not find implicit value for evidence parameter of type Foo.TypedType[String]
             // value bar is not a member of String

  "test".copy() // could not find implicit value for evidence parameter of type Foo.TypedType[String]
}
@scabug
Copy link
Author

scabug commented Oct 12, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7907?orig=1
Reporter: @cvogt
Affected Versions: 2.10.3, 2.11.0-M5
See #7906

@scabug
Copy link
Author

scabug commented Oct 12, 2013

@cvogt said:
Hubert, Jason, is one of your two the right person to investigate this?

@scabug
Copy link
Author

scabug commented Oct 12, 2013

@cvogt said:
I discovered it from investigating this SO post: http://stackoverflow.com/questions/19333322/slick-reusable-insertandupdate-trait/19334767#19334767

@scabug
Copy link
Author

scabug commented Oct 23, 2013

@retronym said:
case classes and copy are red herrings.

object Foo{
  trait TypedType[T]
  implicit def intColumnType: TypedType[Int] = null
  case class ConstColumn[T](v: T){
    def bar() = 5
    def baz = 5
  }
  implicit def valueToConstColumn[T : TypedType](v: T) = ConstColumn(v)
  5.copy()
  5.bar()
  5.baz

  "test".copy()
  "test".bar()
  "test".baz
}
scalac-hash v2.11.0-M5 sandbox/test.scala
[info] v2.11.0-M5 => /Users/jason/usr/scala-v2.11.0-M5-0-gd6fe890
sandbox/test.scala:13: error: could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".copy()
  ^
sandbox/test.scala:14: error: could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".bar()
  ^
sandbox/test.scala:15: error: could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".baz
  ^
sandbox/test.scala:15: error: value baz is not a member of String
  "test".baz
         ^
four errors found

The error messages you desired appeared in 2.11.0-M6. I'm 99% sure this was due to my changes in scala/scala#3024.

% scalac-hash v2.11.0-M6 sandbox/test.scala
[info] v2.11.0-M6 => /Users/jason/usr/scala-v2.11.0-M6-0-g686fb48
sandbox/test.scala:13: error: could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".copy()
  ^
sandbox/test.scala:13: error: value copy is not a member of String
  "test".copy()
         ^
sandbox/test.scala:14: error: could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".bar()
  ^
sandbox/test.scala:14: error: value bar is not a member of String
  "test".bar()
         ^
sandbox/test.scala:15: error: could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".baz
  ^
sandbox/test.scala:15: error: value baz is not a member of String
  "test".baz
         ^
6 errors found

But, the only constant is change, and after the fix for #3346:

git show master~13
commit 54707cb45018170e31eb188a9a694ab9b0728f71
Merge: 5b2c464 210dbc7
Author: Eugene Burmako <xeno.by@gmail.com>
Date:   Fri Oct 18 07:22:58 2013 -0700

    Merge pull request #3030 from xeno-by/topic/fundep-views

    SI-3346 implicit parameters can now guide implicit view inference

% scalac-hash master~13 sandbox/test.scala
[info] master~13 => /Users/jason/usr/scala-v2.11.0-M6-20-g54707cb
sandbox/test.scala:13: error: value copy is not a member of String
  "test".copy()
         ^
sandbox/test.scala:14: error: value bar is not a member of String
  "test".bar()
         ^
sandbox/test.scala:15: error: value baz is not a member of String
  "test".baz
         ^
three errors found

No implicit error messages. But at least it is uniform.

My only suggestion is to compile with -Xlog-implicits:

scalac-hash master~13 -Xlog-implicits sandbox/test.scala
[info] master~13 => /Users/jason/usr/scala-v2.11.0-M6-20-g54707cb
sandbox/test.scala:13: valueToConstColumn is not a valid implicit value for String("test") => ?{def copy: ?} because:
could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".copy()
  ^
sandbox/test.scala:13: valueToConstColumn is not a valid implicit value for (=> String("test")) => ?{def copy: ?} because:
could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".copy()
  ^
sandbox/test.scala:13: error: value copy is not a member of String
  "test".copy()
         ^
sandbox/test.scala:14: valueToConstColumn is not a valid implicit value for String("test") => ?{def bar: ?} because:
could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".bar()
  ^
sandbox/test.scala:14: valueToConstColumn is not a valid implicit value for (=> String("test")) => ?{def bar: ?} because:
could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".bar()
  ^
sandbox/test.scala:14: error: value bar is not a member of String
  "test".bar()
         ^
sandbox/test.scala:15: valueToConstColumn is not a valid implicit value for String("test") => ?{def baz: ?} because:
could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".baz
  ^
sandbox/test.scala:15: valueToConstColumn is not a valid implicit value for (=> String("test")) => ?{def baz: ?} because:
could not find implicit value for evidence parameter of type Foo.TypedType[String]
  "test".baz
  ^
sandbox/test.scala:15: error: value baz is not a member of String
  "test".baz
         ^
three errors found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants