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

Allow SAM types to contain multiple refinements #20172

Merged
merged 1 commit into from
Apr 12, 2024
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5965,7 +5965,7 @@ object Types extends TypeUtils {
def withRefinements(toType: Type, fromTp: Type): Type = fromTp.dealias match
case RefinedType(fromParent, name, info: AliasingBounds) if tp0.member(name).exists =>
val parent1 = withRefinements(toType, fromParent)
RefinedType(toType, name, info)
RefinedType(parent1, name, info)
case _ => toType
val tp = withRefinements(tp0, origTp)

Expand Down
7 changes: 7 additions & 0 deletions tests/run/i18315.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@ trait Sam2:
type T
def apply(x: T): T

trait Sam3:
type T
type U
def apply(x: T): U

object Test:
def main(args: Array[String]): Unit =
val s1: Sam1 { type T = String } = x => x.trim
s1.apply("foo")
val s2: Sam2 { type T = Int } = x => x + 1
s2.apply(1)
val s3: Sam3 { type T = Int; type U = String } = x => x.toString
s3.apply(2)
Loading