Skip to content

Fix #7980: SAM type should check trait parameters #7983

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

Merged
merged 2 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4518,7 +4518,9 @@ object Types {
case et: ExprType => true
case _ => false
}
if (tp.cls.is(Trait) || zeroParams(tp.cls.primaryConstructor.info)) tp // !!! needs to be adapted once traits have parameters
// `ImplicitFunctionN` does not have constructors
val ctor = tp.cls.primaryConstructor
if (!ctor.exists || zeroParams(ctor.info)) tp
else NoType
case tp: AppliedType =>
zeroParamClass(tp.superType)
Expand Down
7 changes: 7 additions & 0 deletions tests/neg/i7980.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trait Evidence[X]

trait Trait[X : Evidence]
def method(x : X) : X

given ev : Evidence[Int] = new Evidence[Int]{}
val crash : Trait[Int] = (x: Int) => x // error