Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When checking for a non-empty type intersection don't treat Singleton…
… as final inferTypedPattern checks for a non-empty intersection between the static type of the scrutinee and the inferred pattern type using Type#isPopulated. The latter has a shortcut execution path for final classes which accidentally picks up Singleton (it's a class and has the FINAL flag set, so that's understandable). However all singleton types are at least conceptually subtypes of Singleton so this leads to incorrect behaviour in cases of the form, Tuple1[Foo.type](Foo) match { case Tuple1(foo: Singleton) => foo } error: pattern type is incompatible with expected type; found : Singleton required: Test.Foo.type case Tuple1(foo: Singleton) => foo ^ one error found This PR fixes that by adding a check that the shortcut is only followed if the type isn't Singleton and also makes a similar change in isEffectivelyFinal. This turned out to be the cause of, typelevel#152 reported against the SIP-23 literal types extension, but as can be seen the example here it's an issue for singleton types generally.
- Loading branch information