File tree 3 files changed +11
-2
lines changed
lib/src/transformer/_core 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,12 @@ import 'unique_namer.dart';
66
66
return (value, type);
67
67
}
68
68
} else if (type is OptionalType ) {
69
- final (newValue, newType) = maybeUnwrapValue (type.child, '$value ?' );
69
+ final optValue = '$value ?' ;
70
+ var (newValue, newType) = maybeUnwrapValue (type.child, optValue);
71
+ if (newValue == optValue) {
72
+ // newValue is value?, so the ? isn't necessary and causes compile errors.
73
+ newValue = value;
74
+ }
70
75
return (newValue, OptionalType (newType));
71
76
} else {
72
77
throw UnimplementedError ('Unknown type: $type ' );
Original file line number Diff line number Diff line change 1
1
import Foundation
2
2
3
- // public func funcOptionalPrimitiveReturn() -> Int? { return 123 }
4
3
public func funcOptionalClassReturn( ) -> MyClass ? { return MyClass ( label: nil ) }
5
4
public func funcOptionalStructReturn( ) -> MyStruct ? { return nil }
6
5
public func funcOptionalArgs( label param: MyClass ? ) -> MyClass { return param! }
7
6
public func funcMultipleOptionalArgs(
8
7
label1 param1: MyClass ? , label2 param2: Int , label3 param3: MyStruct ? ) { }
8
+ public func funcOptionalStrings( str: String ? ) -> String ? { return str; }
9
9
10
10
public var globalOptional : MyStruct ?
11
11
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ import Foundation
17
17
return MyClassWrapper ( result)
18
18
}
19
19
20
+ @objc static public func funcOptionalStringsWrapper( str: String ? ) -> String ? {
21
+ return funcOptionalStrings ( str: str)
22
+ }
23
+
20
24
@objc static public func funcOptionalClassReturnWrapper( ) -> MyClassWrapper ? {
21
25
let result = funcOptionalClassReturn ( )
22
26
return result == nil ? nil : MyClassWrapper ( result!)
You can’t perform that action at this time.
0 commit comments