@@ -1016,10 +1016,9 @@ instance Checkable Expr where
1016
1016
when (null clauses) $
1017
1017
tcError EmptyMatchClauseError
1018
1018
eArg <- typecheck arg
1019
+ checkMatchArgument eArg
1019
1020
let argType = AST. getType eArg
1020
- when (isActiveSingleType argType) $
1021
- unless (isThisAccess arg) $
1022
- tcError ActiveMatchError
1021
+
1023
1022
eClauses <- mapM (checkClause argType) clauses
1024
1023
checkForPrivateExtractors eArg (map mcpattern eClauses)
1025
1024
resultType <- checkAllHandlersSameType eClauses
@@ -1028,6 +1027,16 @@ instance Checkable Expr where
1028
1027
eClauses' = map updateClauseType eClauses
1029
1028
return $ setType resultType match {arg = eArg, clauses = eClauses'}
1030
1029
where
1030
+ checkMatchArgument arg = do
1031
+ let argType = AST. getType arg
1032
+ when (isActiveSingleType argType) $
1033
+ unless (isThisAccess arg) $
1034
+ tcError ActiveMatchError
1035
+ when (any isBottomType (typeComponents argType)) $
1036
+ pushError arg BottomTypeInferenceError
1037
+ when (any isNullType (typeComponents argType)) $
1038
+ pushError arg NullTypeInferenceError
1039
+
1031
1040
checkForPrivateExtractors arg = mapM (checkForPrivateExtractor arg)
1032
1041
1033
1042
checkForPrivateExtractor matchArg p@ ExtractorPattern {name, arg} = do
@@ -1288,7 +1297,7 @@ instance Checkable Expr where
1288
1297
-- E |- expr : t
1289
1298
-- E |- currentMethod : _ -> t
1290
1299
-- -----------------------------
1291
- -- E |- return expr : t
1300
+ -- E |- return expr : _|_
1292
1301
doTypecheck ret@ (Return {val}) =
1293
1302
do eVal <- typecheck val
1294
1303
context <- asks currentExecutionContext
@@ -1302,7 +1311,7 @@ instance Checkable Expr where
1302
1311
unlessM (eType `subtypeOf` ty) $
1303
1312
pushError ret $ ExpectingOtherTypeError
1304
1313
(show ty ++ " (type of the enclosing method or function)" ) eType
1305
- return $ setType eType ret {val = eVal}
1314
+ return $ setType bottomType ret {val = eVal}
1306
1315
1307
1316
-- isStreaming(currentMethod)
1308
1317
-- ----------------------------
@@ -2009,10 +2018,7 @@ coercedInto actual expected
2009
2018
unless (canBeNull expected) $
2010
2019
tcError $ CannotBeNullError expected
2011
2020
return expected
2012
- | isBottomType actual = do
2013
- when (any isBottomType $ typeComponents expected) $
2014
- tcError BottomTypeInferenceError
2015
- return expected
2021
+ | isBottomType actual = return expected
2016
2022
| isBottomType expected =
2017
2023
tcError BottomTypeInferenceError
2018
2024
| otherwise = do
0 commit comments