@@ -2138,7 +2138,7 @@ ImportedType ClangImporter::Implementation::importFunctionReturnType(
21382138 assert (clangEnum.value ()->getIntegerType ()->getCanonicalTypeInternal () ==
21392139 typedefType->getCanonicalTypeInternal ());
21402140 if (auto swiftEnum = importDecl (*clangEnum, CurrentVersion)) {
2141- return {cast<NominalTypeDecl >(swiftEnum)->getDeclaredType (), false };
2141+ return {cast<TypeDecl >(swiftEnum)->getDeclaredInterfaceType (), false };
21422142 }
21432143 }
21442144 }
@@ -2204,7 +2204,8 @@ ImportedType ClangImporter::Implementation::importFunctionParamsAndReturnType(
22042204 assert (clangEnum.value ()->getIntegerType ()->getCanonicalTypeInternal () ==
22052205 typedefType->getCanonicalTypeInternal ());
22062206 if (auto swiftEnum = importDecl (*clangEnum, CurrentVersion)) {
2207- importedType = {cast<NominalTypeDecl>(swiftEnum)->getDeclaredType (), false };
2207+ importedType = {cast<TypeDecl>(swiftEnum)->getDeclaredInterfaceType (),
2208+ false };
22082209 }
22092210 }
22102211 }
@@ -2305,7 +2306,7 @@ ClangImporter::Implementation::importParameterType(
23052306 ->getCanonicalTypeInternal () ==
23062307 typedefType->getCanonicalTypeInternal ());
23072308 if (auto swiftEnum = importDecl (*clangEnum, CurrentVersion)) {
2308- swiftParamTy = cast<NominalTypeDecl >(swiftEnum)->getDeclaredType ();
2309+ swiftParamTy = cast<TypeDecl >(swiftEnum)->getDeclaredInterfaceType ();
23092310 }
23102311 }
23112312 }
@@ -2592,7 +2593,11 @@ ArgumentAttrs ClangImporter::Implementation::inferDefaultArgument(
25922593 // behave like a C enum in the presence of C++.
25932594 auto enumName = typedefType->getDecl ()->getName ();
25942595 ArgumentAttrs argumentAttrs (DefaultArgumentKind::None, true , enumName);
2595- for (auto word : llvm::reverse (camel_case::getWords (enumName))) {
2596+ auto camelCaseWords = camel_case::getWords (enumName);
2597+ for (auto it = camelCaseWords.rbegin (); it != camelCaseWords.rend ();
2598+ ++it) {
2599+ auto word = *it;
2600+ auto next = std::next (it);
25962601 if (camel_case::sameWordIgnoreFirstCase (word, " options" )) {
25972602 argumentAttrs.argumentKind = DefaultArgumentKind::EmptyArray;
25982603 return argumentAttrs;
@@ -2603,13 +2608,17 @@ ArgumentAttrs ClangImporter::Implementation::inferDefaultArgument(
26032608 return argumentAttrs;
26042609 if (camel_case::sameWordIgnoreFirstCase (word, " action" ))
26052610 return argumentAttrs;
2606- if (camel_case::sameWordIgnoreFirstCase (word, " controlevents" ))
2611+ if (camel_case::sameWordIgnoreFirstCase (word, " events" ) &&
2612+ next != camelCaseWords.rend () &&
2613+ camel_case::sameWordIgnoreFirstCase (*next, " control" ))
26072614 return argumentAttrs;
26082615 if (camel_case::sameWordIgnoreFirstCase (word, " state" ))
26092616 return argumentAttrs;
26102617 if (camel_case::sameWordIgnoreFirstCase (word, " unit" ))
26112618 return argumentAttrs;
2612- if (camel_case::sameWordIgnoreFirstCase (word, " scrollposition" ))
2619+ if (camel_case::sameWordIgnoreFirstCase (word, " position" ) &&
2620+ next != camelCaseWords.rend () &&
2621+ camel_case::sameWordIgnoreFirstCase (*next, " scroll" ))
26132622 return argumentAttrs;
26142623 if (camel_case::sameWordIgnoreFirstCase (word, " edge" ))
26152624 return argumentAttrs;
@@ -2896,7 +2905,8 @@ ImportedType ClangImporter::Implementation::importMethodParamsAndReturnType(
28962905 assert (clangEnum.value ()->getIntegerType ()->getCanonicalTypeInternal () ==
28972906 typedefType->getCanonicalTypeInternal ());
28982907 if (auto swiftEnum = importDecl (*clangEnum, CurrentVersion)) {
2899- importedType = {cast<NominalTypeDecl>(swiftEnum)->getDeclaredType (), false };
2908+ importedType = {cast<TypeDecl>(swiftEnum)->getDeclaredInterfaceType (),
2909+ false };
29002910 }
29012911 }
29022912 }
0 commit comments