You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
caseclassCaseClass(a: Int)
objectProductMatch_CaseClass {
defunapply(int: Int):CaseClass=CaseClass(int)
}
objectProductMatch_NamedTuple {
defunapply(int: Int): (a: Int) = (a = int)
}
objectNameBasedMatch_CaseClass {
defunapply(int: Int):Some[CaseClass] =Some(CaseClass(int))
}
objectNameBasedMatch_NamedTuple {
defunapply(int: Int):Some[(a: Int)] =Some((a = int))
}
objectTest {
valProductMatch_CaseClass(a = x1) =1// pattern's type (x1 : Int) is more specialized than the right hand side expression's type IntvalProductMatch_NamedTuple(a = x2) =2// pattern binding uses refutable extractor `org.test.ProductMatch_NamedTuple`valNameBasedMatch_CaseClass(a = x3) =3// pattern's type (x3 : Int) is more specialized than the right hand side expression's type IntvalNameBasedMatch_NamedTuple(a = x4) =4// pattern's type (x4 : Int) is more specialized than the right hand side expression's type IntvalCaseClass(a = x5) =CaseClass(5) // pattern's type (x5 : Int) is more specialized than the right hand side expression's type Intval (a = x6) = (a =6) // ok
}
Output
/home/tobi/workspace/test-projects/named-tuples/src/main/scala/org/test/Test.scala:24:40
pattern'stype (x1 : Int) is more specialized than the right hand side expression'stypeIntIf the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
which may result in a MatchError at runtime.
This patch can be rewritten automatically under -rewrite -source 3.2-migration.
valProductMatch_CaseClass(a = x1) =1/home/tobi/workspace/test-projects/named-tuples/src/main/scala/org/test/Test.scala:25:30
pattern binding uses refutable extractor `org.test.ProductMatch_NamedTuple`
Ifthis usage is intentional, this can be communicated by adding `: @unchecked` after the expression,
which may result in a MatchError at runtime.
This patch can be rewritten automatically under -rewrite -source 3.2-migration.
valProductMatch_NamedTuple(a = x2) =2/home/tobi/workspace/test-projects/named-tuples/src/main/scala/org/test/Test.scala:26:42
pattern'stype (x3 : Int) is more specialized than the right hand side expression'stypeIntIf the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
which may result in a MatchError at runtime.
This patch can be rewritten automatically under -rewrite -source 3.2-migration.
valNameBasedMatch_CaseClass(a = x3) =3/home/tobi/workspace/test-projects/named-tuples/src/main/scala/org/test/Test.scala:27:43
pattern'stype (x4 : Int) is more specialized than the right hand side expression'stypeIntIf the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
which may result in a MatchError at runtime.
This patch can be rewritten automatically under -rewrite -source 3.2-migration.
valNameBasedMatch_NamedTuple(a = x4) =4/home/tobi/workspace/test-projects/named-tuples/src/main/scala/org/test/Test.scala:29:36
pattern'stype (x5 : Int) is more specialized than the right hand side expression'stypeIntIf the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
which may result in a MatchError at runtime.
This patch can be rewritten automatically under -rewrite -source 3.2-migration.
valCaseClass(a = x5) =CaseClass(5)
Expectation
All of the above cases should be irrefutable and not produce warnings
The text was updated successfully, but these errors were encountered:
Compiler version
3.7.1-RC1-bin-20250328-d519790-NIGHTLY
Minimized code
Output
Expectation
All of the above cases should be irrefutable and not produce warnings
The text was updated successfully, but these errors were encountered: