-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make parameter types for inline classes nullable when underlying type…
… is not primitive Updates default parameter conversion to ensure that Kotlin doesn't generate a non-null check when underlying type is not primitive. Test: added compiler tests Fixes: 330655412 ( https://issuetracker.google.com/issues/330655412 ) Change-Id: Ie6bb527824c8542a0f922984f73f4af367ff21ac ( https://android-review.googlesource.com/q/Ie6bb527824c8542a0f922984f73f4af367ff21ac ) Moved from: androidx/androidx@13c32b7
- Loading branch information
Showing
6 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
....kotlin.ComposerParamTransformTests/composeValueClassDefaultParameter[useFir = false].txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Source | ||
// ------------------------------------------ | ||
|
||
import androidx.compose.runtime.* | ||
|
||
@Composable fun Example(data: Data = Data(""), intData: IntData = IntData(0)) {} | ||
|
||
// | ||
// Transformed IR | ||
// ------------------------------------------ | ||
|
||
@Composable | ||
fun Example(data: Data?, intData: IntData, %composer: Composer?, %changed: Int, %default: Int) { | ||
%composer = %composer.startRestartGroup(<>) | ||
sourceInformation(%composer, "C(Example)P(0:Data,1:IntData):Test.kt") | ||
if (%changed and 0b0001 != 0 || !%composer.skipping) { | ||
if (%default and 0b0001 != 0) { | ||
data = Data("") | ||
} | ||
if (%default and 0b0010 != 0) { | ||
intData = IntData(0) | ||
} | ||
if (isTraceInProgress()) { | ||
traceEventStart(<>, %changed, -1, <>) | ||
} | ||
if (isTraceInProgress()) { | ||
traceEventEnd() | ||
} | ||
} else { | ||
%composer.skipToGroupEnd() | ||
} | ||
%composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int -> | ||
Example(data, intData, %composer, updateChangedFlags(%changed or 0b0001), %default) | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...s.kotlin.ComposerParamTransformTests/composeValueClassDefaultParameter[useFir = true].txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Source | ||
// ------------------------------------------ | ||
|
||
import androidx.compose.runtime.* | ||
|
||
@Composable fun Example(data: Data = Data(""), intData: IntData = IntData(0)) {} | ||
|
||
// | ||
// Transformed IR | ||
// ------------------------------------------ | ||
|
||
@Composable | ||
fun Example(data: Data?, intData: IntData, %composer: Composer?, %changed: Int, %default: Int) { | ||
%composer = %composer.startRestartGroup(<>) | ||
sourceInformation(%composer, "C(Example)P(0:Data,1:IntData):Test.kt") | ||
if (%changed and 0b0001 != 0 || !%composer.skipping) { | ||
if (%default and 0b0001 != 0) { | ||
data = Data("") | ||
} | ||
if (%default and 0b0010 != 0) { | ||
intData = IntData(0) | ||
} | ||
if (isTraceInProgress()) { | ||
traceEventStart(<>, %changed, -1, <>) | ||
} | ||
if (isTraceInProgress()) { | ||
traceEventEnd() | ||
} | ||
} else { | ||
%composer.skipToGroupEnd() | ||
} | ||
%composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int -> | ||
Example(data, intData, %composer, updateChangedFlags(%changed or 0b0001), %default) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters